local shizhan = fk.CreateSkill{
    name = "ym2__shizhan",
}
Fk:loadTranslationTable{
    ["ym2__shizhan"] = "试盏",
    [":ym2__shizhan"] = "出牌阶段限X次，你可以弃置一张牌，视为使用【散】。你使用【散】后，本回合使用的下一张【杀】具有【雌雄双股剑】的效果。（X为你失去过的装备牌的副类别数，至少为1）",
    ["@@ym2__shizhan-turn"] = "试盏",
}
shizhan:addEffect("viewas",{
    name = "ym2__shizhan-view",
    pattern = "ym__drugs",
    card_filter = function (self, player, to_select, selected)
        local card = Fk:getCardById(to_select)
        return #selected == 0 and not player:prohibitDiscard(card)
    end,
    view_as = function (self, player, cards)
        if #cards ~= 1 then return end
        local card = Fk:cloneCard("drugs")
        card.skillName = shizhan.name
        card:addFakeSubcards(cards)
        return card
    end,
    before_use = function (self, player, use)
        local room = player.room
        room:throwCard(use.card.fake_subcards,shizhan.name,player)
    end,
    enabled_at_play = function(self, player)
        return player:usedEffectTimes(self.name,Player.HistoryPhase) < math.max(1,#player:getTableMark("ym2__shizhan"))
    end,
    enabled_at_response = Util.FalseFunc,
    times = function (self, player)
        return player.phase == Player.Play and (math.max(1,#player:getTableMark("ym2__shizhan")) - player:usedEffectTimes(self.name,Player.HistoryPhase)) or -1
    end,
})
shizhan:addEffect(fk.AfterCardsMove, {
    can_refresh = function (self, event, target, player, data)
        return player:hasSkill(shizhan.name, true)
    end,
    on_refresh = function (self, event, target, player, data)
        local room = player.room
        if event == fk.AfterCardsMove then
            local mark = player:getTableMark("ym2__shizhan")
            for _, move in ipairs(data) do
                if move.from == player then
                    for _, info in ipairs(move.moveInfo) do
                        local card = Fk:getCardById(info.cardId)
                        if (info.fromArea == Card.PlayerEquip or info.fromArea == Card.PlayerHand) and card.type == Card.TypeEquip then
                            table.insertIfNeed(mark,card:getSubtypeString())
                        end
                    end
                end
            end
            if #mark > 0 then
                room:setPlayerMark(player, "ym2__shizhan", mark)
            else
                room:setPlayerMark(player, "ym2__shizhan", 0)
            end
        end
    end,
})
shizhan:addEffect(fk.CardUsing,{
    can_trigger = function (self, event, target, player, data)
        return player == target and player:hasSkill(shizhan.name) and data.card.trueName == "drugs"
    end,
    on_cost = Util.TrueFunc,
    on_use = function (self, event, target, player, data)
        local room = player.room
        room:setPlayerMark(player,"@@ym2__shizhan-turn",1)
    end,
})
shizhan:addEffect(fk.TargetSpecified, {
    mute = true,
    can_refresh = function(self, event, target, player, data)
        if target == player and data.card and data.card.trueName == "slash" and player:getMark("@@ym2__shizhan-turn") ~= 0 then
            player.room:setPlayerMark(player,"@@ym2__shizhan-turn",0)
            return not player:hasSkill("#double_swords_skill") and player:compareGenderWith(data.to, true)
        end
    end,
    on_refresh = function(self, event, target, player, data)
        local room = player.room
        local to = data.to
        if room:askToSkillInvoke(player,{
            skill_name = "#double_swords_skill"
        }) then
            room:broadcastPlaySound("./packages/standard_cards/audio/card/double_swords")
            room:setEmotion(player, "./packages/standard_cards/image/anim/double_swords")
            if to:isKongcheng() then
                player:drawCards(1, "#double_swords_skill")
            else
                local result = room:askToDiscard(to, {
                    min_num = 1,
                    max_num = 1,
                    include_equip = false,
                    skill_name = "#double_swords_skill",
                    cancelable = true,
                    prompt = "#double_swords-invoke:"..player.id,
                })
                if #result == 0 then
                    player:drawCards(1, "#double_swords_skill")
                end
            end
        end
    end,
})
return shizhan